home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Belgian Amiga Club - ADF Collection
/
BS1 part 65.zip
/
BS1 part 65
/
Math Visin v2.1 disk 1.adf
/
Arexx.WB
/
Simple
/
BioRhythm
< prev
next >
Wrap
Text File
|
1992-02-12
|
6KB
|
207 lines
/*BioRhythm Compute your BioRhythm for this year 6-Mar-90 dh
This simply asks for your birthday, and plots your biorhythm for this year.
The year long plot is broken into 6 sections of two months each.
However, there IS a lot of good code in this file dealing with date
arithmetic, input, output, and leap years.
-------------------------------------------------------------------------- */
ADDRESS "MathVision"
NUMERIC DIGITS 14
OPTIONS RESULTS
CycleLength.1 = 0 /* put correct rhythm information here */
CycleLength.2 = 23; CycleName.2 = "Physical (RED)"
CycleLength.3 = 28; CycleName.3 = "Emotional (GREEN)"
CycleLength.4 = 33; CycleName.4 = "Intellectual (BLUE)"
CycleLength.5 = 0
funname.1 = "FA"
funname.2 = "FB"
funname.3 = "FC"
funname.4 = "FD"
funname.5 = "FE"
CALL InitMonth
SAY "The year-long biorhythm is plotted in 6 groups of two months each."
SAY ""
Birth = GetDate("Enter your Birthday, eg. 7 Dec 41: ")
PARSE VAR Birth Birthday BirthMonth BirthYear
CurrentDate = date(S)
CurrentYear = Left(CurrentDate,4)
CurrentMonth = SubStr(CurrentDate,5,2)
CurrentDay = Right(CurrentDate,2)
DaysOffset = DaysBetweenDates( Birthday, BirthMonth, BirthYear, 1, 1, CurrentYear )
Lace "T"
Hires "T"
Depth 3
Width 640
Height 400
ChangeScreen
EraseScreen
SimpleSampleDelta 2
SimpleGradient1 "F"
SimpleGradient2 "F"
OverPlot "T"
XMin 0
XMax 62
YMin .5
YMax 12.5
SimplePen 1
Color 0 0 0 0
Color 1 6 6 6
Color 2 9 0 0
Color 3 0 9 0
Color 4 0 0 9
Color 5 12 12 12
PlotScreenToFront
FA '0 " Baseline (GRAY)'
FE '(fb(a1)+fc(a1)+fd(a1))/3 " Composite (WHITE)'
FF 'Sin((x+a1)*(2*pi)/a2) " generic calculation'
DO i = 2 to 4
T = "FF(a1,"CycleLength.i")"
T = T '"' CycleName.i
Interpret 'Funname.i' 'T'
END
Comment1 "BioRhythm for the Year "CurrentYear", Birthdate "ConvertDate(BirthDay BirthMonth BirthYear)
Comment2 "Months are grouped by twos, eg. top graph is January/February"
Comment3 ""
StopSign "F"
DO Month = 1 to 12 by 2
DO i = 1 to 5
F0 Funname.i"("DaysOffset+MonthDaysAccrued.Month")/1.5+12.5-"Month
SimplePen i
PlotSimple
Get StopSign
IF (Result = "T") THEN EXIT
END
END
exit
/*------------------------------ InitMonth -------------------------------- */
InitMonth: PROCEDURE EXPOSE MonthName. MonthDays. MonthMatch. MonthDaysAccrued.
MonthName.1 = "January" ; MonthDays.1 = 31
MonthName.2 = "February" ; MonthDays.2 = 28
MonthName.3 = "March" ; MonthDays.3 = 31
MonthName.4 = "April" ; MonthDays.4 = 30
MonthName.5 = "May" ; MonthDays.5 = 31
MonthName.6 = "June" ; MonthDays.6 = 30
MonthName.7 = "July" ; MonthDays.7 = 31
MonthName.8 = "August" ; MonthDays.8 = 31
MonthName.9 = "September" ; MonthDays.9 = 30
MonthName.10 = "October" ; MonthDays.10 = 31
MonthName.11 = "November" ; MonthDays.11 = 30
MonthName.12 = "December" ; MonthDays.12 = 31
Total = 0
DO i = 1 to 12
MonthMatch.i = UPPER(Left(MonthName.i,3))
MonthDaysAccrued.i = Total
Total = Total + MonthDays.i
END
RETURN
/*---------------------------- GetDate ---------------------------- */
GetDate: PROCEDURE EXPOSE MonthDays. MonthMatch. /* set Month, Day, Year */
PARSE ARG DatePrompt
OPTIONS PROMPT DatePrompt
IsValid = 0
DO UNTIL IsValid
PULL GDDate
GDDate = Translate( GDDate, "","/,.-():"," " )
PARSE VAR GDDate Day Month Year
if (Year < 1000) THEN Year = Year + 1900 /* year assumed last */
IF DATATYPE(Day,M) /* if month in day position, swap */
THEN DO; T = Month; Month = Day; Day = T; END
IF DATATYPE(Month,M) /* Month alphabetic */
THEN Month = ConvertMonth( Month )
ELSE
DO
IF (Month > 12) | (Day > 31) /* sanity check */
THEN DO; T = Month; Month = Day; Day = T; END
END
IsValid = 0
IF ((Month>=1) & (Month<=12)) & (Day>=1)
THEN IF Day<=MonthDays.Month THEN IsValid = 1
END
RETURN Day Month Year
/*-------------------------- ConvertMonth --------------------------------- */
ConvertMonth: PROCEDURE EXPOSE MonthMatch. /* Convert "March" to "3" */
ARG Month
NumMonth = 0
DO i = 1 to 12
T = compare( month, MonthMatch.i, " " )
IF (T = 0 | T >=4) THEN DO; NumMonth = i; i = 1000;END
END
RETURN NumMonth
/*--------------------------- ConvertDate --------------------------------- */
ConvertDate:
ARG Day Month Year
return STRIP(Day)"-"STRIP(MonthName.Month)"-"STRIP(Year)
/*--------------------------- DayInYear ----------------------------------- */
DayInYear: /* is the xth day of year */
ARG Day Month Year
If (IsLeapYear(Year) & (Month>2))
THEN RETURN MonthDaysAccrued.Month+Day+1
ELSE RETURN MonthDaysAccrued.Month+Day
/* ----------------------------- DaysInYear -------------------------------- */
DaysInYear: /* account for leap years */
ARG DYear
if IsLeapYear(DYear)
THEN RETURN(366)
ELSE RETURN(365)
/* ----------------------------- IsLeapYear ------------------------------- */
IsLeapYear: /* test for leap years */
ARG IsYear
IF (IsYear//4=0)
THEN DO
IF (IsYear//100=0)
THEN DO
IF (IsYear//400=0) THEN RETURN 1 ELSE RETURN 0;
END
ELSE RETURN 1
END
ELSE RETURN 0
/*------------------------------ DaysBetweenYears --------------------------- */
DaysBetweenYears: PROCEDURE /* total of days between years */
ARG StartYear, EndYear
Total = 0
DO Year = StartYear to EndYear-1
Total = Total + DaysInYear(Year)
END
RETURN Total
/*---------------------------- DaysBetweenDates ----------------------------- */
/* total of days between two dates */
DaysBetweenDates: PROCEDURE EXPOSE MonthDaysAccrued.
ARG sday, smonth, syear, eday, emonth, eyear
Days = DaysBetweenYears( syear, eyear )
Days = Days - DayInYear( sday smonth syear )
Days = Days + DayInYear( eday emonth eyear )
RETURN(Days)